import { useToast } from "vue-toastification";
import type {
  ToastID,
  ToastContent,
  ToastOptions,
  PluginOptions,
} from "vue-toastification/dist/types/types";
const toast = useToast();

const $toast = {
  success: (content: ToastContent, options?: PluginOptions) => {
    toast.success(content, options);
  },
  info: (content: ToastContent, options?: PluginOptions) => {
    toast.info(content, options);
  },
  warning: (content: ToastContent, options?: PluginOptions) => {
    toast.warning(content, options);
  },
  error: (content: ToastContent, options?: PluginOptions) => {
    toast.error(content, options);
  },
  clear: () => {
    toast.clear();
  },
  updateDefaults: (update: PluginOptions) => {
    toast.updateDefaults(update);
  },
  dismiss: (id: ToastID) => {
    toast.dismiss(id);
  },
  updateFalse: (
    id: ToastID,
    config: {
      content?: any;
      options?: ToastOptions | undefined;
    },
    create?: false | undefined,
  ) => {
    toast.update(id, config, create);
  },
  updateTrue: (
    id: ToastID,
    config: {
      content: any;
      options?: ToastOptions | undefined;
    },
    create?: true | undefined,
  ) => {
    toast.update(id, config, create);
  },
};

export default $toast;
